<?php
require_once 'const/RequestConst.php';
?>
<html>
    <head>
        <title>Hello Shop, </title>
        <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
        <link href="/css/admin/css.css" rel="stylesheet" type="text/css" />
        <script language="JavaScript" src="/jscript/admin/js.js"></script>
        <script language="JavaScript" src="/jscript/comm/divwindows.js"></script>
        <script type="text/javascript" src="/jscript/editor/tiny_mce.js"></script>
    </head>
    <body>
        <form action="<?php echo "/admin/add-product?id=" . $this->id ?>" method="post" enctype="multipart/form-data" name="form1" target="adminMain" id="form1" onSubmit="return checkData();">
            <div id="divMainBodyTop">
                <div class="fLeft"><img src="/images/default/admin/edit.gif" width="15" height="13"></div>
                <div>添加商品</div>
            </div>
            <div id="BodyContent">
                <div class="cls"></div>
                <div id="divMainBodyContent">
                    <div id="divMainBodyContentTitle">类别:</div>
                    <div id="hiddenselect" class="fLeft">
                        <select class="txInput"  name="<?php echo P_TYPE_ID ?>" id="cid">
                            <?php foreach ($this->types as $type): ?>
                                <option value="<?php echo $type["ID"] ?>" selected><?php echo $type["NAME"] ?></option>
                            <?php endforeach; ?>
                            </select>
                        </div>
                        <div class="cls"></div>
                    </div>
                    <div id="divMainBodyContent">
                        <div id="divMainBodyContentTitle">产品名称:</div>
                        <div class="fLeft">
                            <input class="txInput" name="<?php echo P_NAME ?>" type="text" value="<?php echo $this->product[C_NAME] ?>">
                                        		   库存:<input class="txInput" name="<?php echo P_NUM ?>" type="text" size="5" maxlength="5" value="<?php echo $this->product[C_NUM] ?>">
                            </div>
                            <div class="cls"></div>
                        </div>
                        <div id="divMainBodyContent">
                            <div id="divMainBodyContentTitle"> 售价:</div>
                            <div class="fLeft"><input name="<?php echo P_PRICE ?>" type="text" class="txInput" value="<?php echo $this->product[C_PRICE] ?>" size="9">
                            </div>
                            <div class="cls"></div>
                        </div>
                        <div id="divMainBodyContent">
                            <div id="divMainBodyContentTitle"> 描述:</div>
                            <div class="fLeft" style="height:300px;">
                                <textarea id="product_des"  name="<?php echo P_DESCRIPTION ?>"  rows="15" cols="50" style="width:98%"><?php echo $this->product[C_DESCRIPTION] ?></textarea>
                            </div>
                            <div class="cls"></div>
                        </div>
                        <div id="divMainBodyContent">
                            <div id="divMainBodyContentTitle"> 图片:</div>
                            <div class="fLeft">
                                <input class="txInput" name="product_b" type="file" value="">
                            </div>
                            <div></div>
                            <div class="cls"></div>
                        </div>                        
                        <div class="cls"></div>
                <?php if ($this->id): ?>
                                    <div id="divMainBodyContent">
                                        <div id="divMainBodyContentTitle"> 预览:</div>
                                        <div class="fLeft">
                                            <img height="200" src="<?php echo "/upload/" . $this->id ?>" alt="pic" />
                                        </div>
                                        <div></div>
                                        <div class="cls"></div>
                                    </div>
                <?php endif; ?>
                <div class="cls"></div>
            </div>
            <div id="divMainBodyContentSumbit">
                <input name="ok" type="submit" value="  o  k  " class="txInput">
                <input name="reset" type="reset" value="reset" class="txInput">
            </div>
        </form>
        <script language="javascript">
            function checkData() {
                /*if(document.form1.nopic.checked == true && document.form1.product_no.value == '') {
                        alert('编号不能为空！');
                        document.form1.product_no.focus;
                        return false;
                }*/
                if(document.form1.product_name.value == '') {
                    alert('品名不能为空！');
                    document.form1.product_name.focus;
                    return false;
                }
                if(document.form1.product_price.value == '') {
                    alert('售价不能为空！');
                    document.form1.product_price.focus;
                    return false;
                }
            }
            classesFix();
        </script>
    </body>
</html>